package com.blocks.mq.producer.example.service;

import com.blocks.mq.producer.entity.Student;
import com.blocks.mq.producer.repository.StudentRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * @author lxd
 * @date 2020/12/4 23:48
 */
@Service
public class ExampleDatabaseService {

    @Resource
    StudentRepository studentRepository;

    public Student getById(Integer id) {
        Optional<Student> optional = studentRepository.findById(id);
        return optional.orElse(null);
    }

    public List<Student> getAllStudent() {
        return studentRepository.findAll();
    }

}
